package com.gsh.controller;

import com.alibaba.fastjson.JSON;
import com.gsh.config.JsonTest;
import com.gsh.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;


@RestController
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/login")
    public String login(@RequestParam(name="username") String username,
                        @RequestParam(name="password") String password){
        int i= userService.queryBypw(username,password);
        JsonTest json=new JsonTest();
        if(i<=0){
            json.setCode(400);
            json.setMsg("用户名或密码错误，请重新输入！");
        }else {
            json.setCode(200);
            json.setMsg("登录成功！");
        }
        return JSON.toJSONString(json);
    }
}
